﻿@namespace CyssBlazor.Shared.Components
@if (ChildContent != null)
{
    <div class="dropdown" style="display: initial">
        <button type="button" class="@ClassName" data-bs-toggle="dropdown" aria-expanded="true">
            <i class="@Icon"></i>
            @Text
        </button>
        <div class="dropdown-menu" data-popper-placement="bottom-start">
            @ChildContent
        </div>
    </div>
}
@code
{

    [Parameter]
    public string Text { set; get; } = "操作";

    /// <summary>
    /// 获得/设置 显示图标
    /// </summary>
    [Parameter]
    public string? Icon { get; set; }


    /// <summary>
    /// 获得/设置 按钮颜色
    /// </summary>
    [Parameter]
    public Color Color { get; set; } = Color.Primary;

    /// <summary>
    /// 获得/设置 Size 大小
    /// </summary>
    [Parameter]
    public Size Size { get; set; } = Size.None;
    /// <summary>
    /// 获得/设置 TableHeader 实例
    /// </summary>
    [Parameter]
    public RenderFragment? ChildContent { get; set; }

    /// <summary>
    /// 获得 按钮样式集合
    /// </summary>
    /// <returns></returns>
    protected string? ClassName => CssBuilder.Default("btn dropdown-toggle")
        .AddClass($"btn-{Color.ToDescriptionString()}", Color != Color.None)
        .AddClass($"btn-{Size.ToDescriptionString()}", Size != Size.None)
        .Build();

}